//
//  STDSAttribStroke.cpp
//  STDSRenderSDKIOS
//
//  Created by 陈学明 on 2023/3/27.
//

#include "STDSAttribStroke.hpp"

STDSAttribStroke::STDSAttribStroke() {
    mCountParticle = 1;
    mCountVertices = 3;
    mUseIdx = true;
    _reset();
}

void STDSAttribStroke::draw(std::vector<int> &_idxSize, vector<int>_idxArr, vector<float>_vexArr) {
    if (_idxSize.empty() || _idxArr.size() == 0 || 0 == _vexArr.size())
        return;

    glBindBuffer(GL_ARRAY_BUFFER, 0);

    glVertexAttribPointer((GLuint) mPosVex, 3, GL_FLOAT, GL_FALSE, 0, _vexArr.data());
    glEnableVertexAttribArray((GLuint) mPosVex);

    int off = 0;
    int count = 0;
    for (int i = 0; i < _idxSize.size(); ++i) {
        count = _idxSize[i];
        mDrawFunc(&_idxArr[off], count, 0);
        off += count;
    }
    glBindBuffer(GL_ARRAY_BUFFER, 0);
}

void STDSAttribStroke::_resetDrawFunc() {
    mDrawFunc = STDSGLFunctions::draw_ELE_TRIANGLES;
}
